package cn.gson.springmvc.controller;

import cn.gson.springmvc.model.pojos.Dept;
import cn.gson.springmvc.model.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class DemoController {
    @Autowired
    DeptService ds;

    @RequestMapping("/demo")
    public void demo(Model model){
        model.addAttribute("list",ds.findAll());
    }

    @RequestMapping("/add-dept")
    public String addDept(Dept dept){
        ds.addDept(dept);
        return "redirect:demo";
    }
}
